package com.ruoyi.web.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.Athlete;
import com.ruoyi.system.domain.Couch;
import com.ruoyi.system.service.ICoachService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author Ly lilongfei
 * @date 2024/8/23
 * @Description
 */
@RestController
public class CouchController {

    @Autowired
    private ICoachService coachService;

    /**
     * 根据项目id查询教练接口
     * 数据上传的前提
     * @param projectId
     * @return
     */
    @PostMapping("/findCouchByProjectId")
    public AjaxResult findCouchByProjectId(Integer projectId) {
        List<Couch> couchList = coachService.findCouchListByProject(projectId);
        if(couchList.isEmpty()){
            throw new RuntimeException("未查询到教练,请确认项目");
        }
        //去重
        List<Couch> uniqueList = couchList.stream().distinct().collect(Collectors.toList());
        return AjaxResult.success(uniqueList);
    }

}
